<?php
/**
 * 2018-07-13 by 我是个导演
 * 欢迎访问支付宝论坛：https://openclub.alipay.com/index.php
 *
 * APP支付 RSA2签名方法生成二维码版本
 */
//引入核心库文件
require_once 'phpqrcode/phpqrcode.php';
require_once 'AopSdk.php';
$aop = new AopClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';

// $aop->appId = '填写您的appid';
// $aop->rsaPrivateKey = '填写您的原始私钥';
// $aop->alipayrsaPublicKey = '填写您的支付宝公钥';
$aop->appId = '2021001164698990'; //$configura['payAppidZfb']; // APP ID 应用ID
$aop->rsaPrivateKey = 'MIIEogIBAAKCAQEApY7TiMN60wf1CoGSS6lkaIw3+xNazmaQdR1OCmMyE4o6Cbcw7Jw0VWnR+CJCurG+g/+V2EfypLOvIS1vOWBTFnp7ddXlKP2tkTPzAEwV6VHqI6HUARRbua2cXloLYH+uKDTypW7HSSZ6oltHV459T6viBvYIpdLDDvCRdV4+FRHuqp1uVJL/nCSGJTRtP9esXx9gVuLtETdyfZjpRyiRSgSTfVLkuPhn/ySJULEfJOFHP9F8taXjTLw1ZcrN4vSBOcFUQY9kNHxJUSTvmAka8t8MKLxy4H7aduAKBz4BJfItfnXt04vZ3rUvT6/FiBMEuo6OHQOjmIUvGQw/eLazWQIDAQABAoIBAFBkmrO+uNXg90yyvqefCfL6o/R34ZB4nY1BPbQtlxOF+8jb/BXphEA1spAbkuu1hB307n6n8VupJVGnDmt+Ktqvf2QpCa5uAOqRn151k+5IqLnEy336tM/lThlDAGNLnPZJP8q1kHAlD0fnqy0JNDCL9qYKswhS4AVRLFEiAmOYGNxHebo5+WcP5c5YnxtprR8nKe8RWhQYgYEJC5i2reskxFKrLgJrSR8QcBxkmPqmP0YLhYvwz5nWsKfhuN/grWyvwXfzv6bl/4OjXhsyoRJbOA9W6HrUaDf5au+EUapHcoyTbUsjTlDiv0q0qaU/U/Vcid0zuQHTQoN9ELIxlQECgYEA4UuxPKxMEIbfRrN+Gnl3u6A1JaigZXYFOTtXmX6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ersion = '1.0';
$aop->postCharset = 'utf-8';
$aop->format = 'json';
$aop->signType = 'RSA2';
//生成随机订单号
$date = date("YmdHis");
$arr = range(1000, 9999);
shuffle($arr);
$request = new AlipayTradeAppPayRequest();
//异步地址传值方式
$request->setNotifyUrl("http://app.tuerduo.net/callback/alipay/");
$request->setBizContent("{\"out_trade_no\":\"" . $date . $arr[0] . "\",\"total_amount\":0.01,\"product_code\":\"QUICK_MSECURITY_PAY\",\"subject\":\"app测试\"}");
$result = $aop->sdkExecute($request);
print_r(htmlspecialchars($result));
//定义纠错级别
// $errorLevel = "L";
// //定义生成图片宽度和高度;默认为3
// $size = "3";
// //调用QRcode类的静态方法png生成二维码图片//
// QRcode::png($result, false, $errorLevel, $size);
// //生成网址类型
// $url="https://openclub.alipay.com/index.php";
// $url.="\r\n";
// QRcode::png($url, false, $errorLevel, $size);
?>